package RedBook;

import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-09-25 15:51
 */
public class Main_0925_2 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        cin.nextLine();
        for (int i = 0; i < n; i++) {
            String line1 = cin.nextLine();
            String line2 = cin.nextLine();
            int n1 = line1.length();
            int n2 = line2.length();
            int index1=0,index2=0;
            while (true){
                if (index1== n1){
                    //line1到最后了
                    if (index2==n2){
                        System.out.println("yes");
                        break;
                    }else {
                        System.out.println("no");
                        break;
                    }
                }
                if (index2==n2){
                    //line2到最后了
                    System.out.println("yes");
                    break;
                }
                if (line1.charAt(index1)==line2.charAt(index2)){
                    index1++;
                    index2++;
                }else {
                    index1++;
                }
            }
        }
    }
}
